package com.syyo.gulimall.member.web;

import com.alibaba.fastjson.JSON;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import com.syyo.common.domain.ResultVo;
import com.syyo.gulimall.member.feign.OrderFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.Map;

/**
 * @ author: wang
 * @ date: 2021/5/19 17:22
 * @ Description:
 */
@Controller
public class MemberWebController {

    @Autowired
    OrderFeign orderFeign;

    @GetMapping("/memberOrder.html")
    public String memberOrderPage(@RequestParam(value = "pageNum",defaultValue = "1",required = false)String pageNum,
                                  @RequestParam(value = "pageSize",defaultValue = "20",required = false)String pageSize,
                                  Model model){
        // 获取到支付宝给我们传来的所有参数




        Map<String, Object> params = new HashMap<>();
        ResultVo resultVo = orderFeign.listWithItem(Integer.parseInt(pageNum), Integer.parseInt(pageSize), params);
        model.addAttribute("orders",resultVo);

        System.out.println(JSON.toJSONString(resultVo));
        return "orderList";
    }
}
